@isTest(SeeAllData=true)
private class AddOppMemberHandlerTest {
    static testMethod void testMethod1() {
        Account acc = TestUtils.createAccount();
        acc.name = 'AddOppMemberHandlerTest';
        insert acc;

        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = acc.Id;
        insert opp;

        PlanGroupAssist__c pga = new PlanGroupAssist__c();
        pga.Opportunity__c = opp.Id;
        insert pga;

        Group g = new Group();
        List<Group> gList = [Select Id From Group where DeveloperName='OppCooperationTeam'];
        //g = gmList[0];
        if (gList.size() > 0) {
            g = gList[0];
        } else {
            g.DeveloperName = 'OppCooperationTeam';
            g.Name = 'Test';
            insert g;
        }

        User thisUser = [ select Id from User where Id = :UserInfo.getUserId() ];
        System.runAs ( thisUser ) {

            GroupMember gm = new GroupMember();
            List<GroupMember> gmList = [Select Id From GroupMember where Group.DeveloperName='OppCooperationTeam' and UserOrGroupId = :UserInfo.getUserId()];
            if (gmList.size() > 0) {
                gm = gmList[0];
            } else {
                gm.UserOrGroupId = UserInfo.getUserId();
                gm.GroupId = g.Id;
                insert gm;
            }
            
        }
       

        pga.ApprovalStatus__c = '审核成功';
        update pga;
    }
}